#!usr/bin/env python3

import rclpy
from rclpy.node import Node
from std_msgs.msg import String

class SimplePublisher(Node):
    def __init__(self):
        super().__init__("simple_publisher")
        self.pub_ = self.create_publisher(String, "chater", 10)

        self.counter_ = 0
        self.frequency = 1

        self.get_logger().info("Pubishing at %d Hz" % self.frequency)

        self.create_timer(1 / self.frequency, self.timer_callback)

    def timer_callback(self):
        msg = String()

        msg.data = "Hello ROS2 - counter: %s" % str(self.counter_)

        self.counter_ += 1

        self.pub_.publish(msg)

def main(args=None):
    rclpy.init(args=args)
    node = SimplePublisher()
    rclpy.spin(node)

    rclpy.shutdown()

if __name__ == "__main__":
    main()